﻿jQuery.glimpseElmah = {};

jQuery.extend(jQuery.glimpseElmah, {
    loadPage: function (pageIndex, pageSize) {
        var that = this;
        var static = that.static;

        jQuery.ajax({
            url: static.link,
            type: 'GET',
            data: { 'pageIndex': pageIndex, 'pageSize': pageSize },
            contentType: 'application/json',
            cache: false,
            success: function (data, textStatus, jqXHR) {
                that.refreshTab(static.key, data);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert('error');
            }
        });
    },
    refreshTab: function (key, data) {
        var panelHolder = window.jQueryGlimpse.glimpse.static.panelHolder();
        var tabContentPlaceHolder = jQuery('.glimpse-panelitem-' + key, panelHolder);
        tabContentPlaceHolder.empty();

        var tabContent = window.jQueryGlimpse.glimpseProcessor.build(data, 0);
        tabContentPlaceHolder.html(tabContent);
    },
    static: {
        key: 'Elmah',
        link: '/Glimpse.axd?r=Elmah'
    }
});